<?php
class Person {
    protected $name;
    protected $sex;
    //父类的构造函数
    public function __construct($name,$sex) {
        $this->name=$name;
        $this->sex=$sex;
    }
}
class Student extends Person {
    private $score;
    //子类的构造函数
    public function __construct($name,$sex,$score) {
        parent::__construct($name,$sex);  //调用父类构造函数并传递参数
        $this->score=$score;
    }
    //显示信息
    public function getInfo() {
        echo "姓名：{$this->name}<br>";
        echo "性别：{$this->sex}<br>";
        echo "成绩：{$this->score}";
    }
}
//测试
$stu=new Student('tom','男',88);
$stu->getInfo();
/*
姓名：tom
性别：男
成绩：88
*/
